﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsGame1.Model.Levels
{
    class Level2
    {
        //fält
        private static int  _levelWidth = Level.g_levelWidth;
        private static int  _levelHeight = Level.g_levelHeight;
        internal Tile[,]    _tiles;

        //funktion som bestämmer på hur banan ska se ut
        internal Tile[,] GenerateLevel()
        {
            _tiles = new Tile[_levelWidth, _levelHeight];
            
            for (int x = 0; x < _levelWidth; x++)
            {
                for (int y = 0; y < _levelHeight; y++)
                {
                    _tiles[x, y] = new Tile();
                }
            }

            //Enemies
            _tiles[25, 15]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            //Mines
            _tiles[10, 17]._tileType = Tile.TileType.T_MINE_SPAWN_POSITION;

            //Carrots
            _tiles[40, 9]._tileType = Tile.TileType.T_CARROT_POSITION;
            _tiles[55, 17]._tileType = Tile.TileType.T_CARROT_POSITION;

            //set spikes at the bottom
            for(int x = 0; x < _levelWidth; x++)
            {
                _tiles[x, 19]._tileType = Tile.TileType.T_TRAP;
            }

            //ground
            for (int x = 0; x < 20; x++)
            {
                _tiles[x, 19]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 18]._tileType = Tile.TileType.T_GROUND;
            }

            //air-ground
            for (int x = 23; x < 26; x++)
            {
                _tiles[x, 16]._tileType = Tile.TileType.T_GROUND;
            }

            for (int x = 29; x < 31; x++)
            {
                _tiles[x, 13]._tileType = Tile.TileType.T_GROUND;
            }

            for (int x = 34; x < 37; x++)
            {
                _tiles[x, 13]._tileType = Tile.TileType.T_GROUND;
            }

            _tiles[36, 12]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;



            _tiles[40, 10]._tileType = Tile.TileType.T_GROUND;


            _tiles[45, 14]._tileType = Tile.TileType.T_GROUND;

            
            //special-stares
            for (int x = 50; x < 80; x++)
            {
                _tiles[x, 18]._tileType = Tile.TileType.T_BLOCKED;
            }
            for (int x = 50; x < 52; x++)
            {
                _tiles[x, 17]._tileType = Tile.TileType.T_GROUND;
            }
            for (int x = 52; x < 53; x++)
            {
                _tiles[x, 17]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 16]._tileType = Tile.TileType.T_GROUND;
            }
            for (int x = 53; x < 54; x++)
            {
                _tiles[x, 16]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 15]._tileType = Tile.TileType.T_GROUND;
            }

            _tiles[55, 15]._tileType = Tile.TileType.T_GROUND;

            for (int x = 54; x < 55; x++)
            {
                _tiles[x, 15]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 14]._tileType = Tile.TileType.T_GROUND;
            }

            //topblock for special stares
            for (int x = 56; x < 100; x++)
            {
                _tiles[x, 12]._tileType = Tile.TileType.T_GROUND;
            }

            //enemies
            _tiles[60, 11]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[65, 11]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[75, 11]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            //carrots
            _tiles[98, 14]._tileType = Tile.TileType.T_CARROT_POSITION;
            _tiles[98, 15]._tileType = Tile.TileType.T_CARROT_POSITION;
            _tiles[98, 16]._tileType = Tile.TileType.T_CARROT_POSITION;

            _tiles[80, 13]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[80, 14]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[80, 17]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[80, 16]._tileType = Tile.TileType.T_GROUND;
            _tiles[80, 18]._tileType = Tile.TileType.T_BLOCKED;

            for (int x = 80; x < 100; x++)
            {
                _tiles[x, 18]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 17]._tileType = Tile.TileType.T_GROUND;
            }

            //enemies in the end of the hole
            _tiles[85, 16]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;
            _tiles[90, 16]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;
            _tiles[95, 16]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[99, 16]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[99, 15]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[99, 14]._tileType = Tile.TileType.T_BLOCKED;
            _tiles[99, 13]._tileType = Tile.TileType.T_BLOCKED;

            //bouncing enemies
            //TODO: add these enemies

            _tiles[104, 14]._tileType = Tile.TileType.T_GROUND;

            _tiles[108, 11]._tileType = Tile.TileType.T_GROUND;

            _tiles[113, 15]._tileType = Tile.TileType.T_GROUND;

            _tiles[117, 12]._tileType = Tile.TileType.T_GROUND;

            _tiles[121, 15]._tileType = Tile.TileType.T_GROUND;

            for (int x = 122; x < 130; x++)
            {
                _tiles[x, 19]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 18]._tileType = Tile.TileType.T_GROUND;
            }

            _tiles[125, 17]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[130, 15]._tileType = Tile.TileType.T_GROUND;

            _tiles[132, 12]._tileType = Tile.TileType.T_GROUND;

            _tiles[132, 9]._tileType = Tile.TileType.T_GROUND;

            _tiles[134, 8]._tileType = Tile.TileType.T_GROUND;

            //the "pipe"
            for (int y = 10; y < 15; y++)
            {
                _tiles[134, y]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[136, y]._tileType = Tile.TileType.T_BLOCKED;
            }

            _tiles[136, 8]._tileType = Tile.TileType.T_GROUND;

            _tiles[135, 18]._tileType = Tile.TileType.T_GROUND;
            _tiles[135, 19]._tileType = Tile.TileType.T_BLOCKED;

            _tiles[140, 18]._tileType = Tile.TileType.T_GROUND;
            _tiles[140, 19]._tileType = Tile.TileType.T_BLOCKED;

            _tiles[145, 15]._tileType = Tile.TileType.T_GROUND;

            _tiles[150, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[151, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[152, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[153, 13]._tileType = Tile.TileType.T_GROUND;

            _tiles[151, 12]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[156, 8]._tileType = Tile.TileType.T_GROUND;
            _tiles[157, 8]._tileType = Tile.TileType.T_GROUND;
            _tiles[158, 8]._tileType = Tile.TileType.T_GROUND;
            _tiles[159, 8]._tileType = Tile.TileType.T_GROUND;

            _tiles[156, 10]._tileType = Tile.TileType.T_GROUND;
            _tiles[157, 10]._tileType = Tile.TileType.T_GROUND;
            _tiles[158, 10]._tileType = Tile.TileType.T_GROUND;
            _tiles[159, 10]._tileType = Tile.TileType.T_GROUND;

            _tiles[164, 12]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[162, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[163, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[164, 13]._tileType = Tile.TileType.T_GROUND;
            _tiles[165, 13]._tileType = Tile.TileType.T_GROUND;

            for (int x = 170; x < 180; x++)
            {
                _tiles[x, 17]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 16]._tileType = Tile.TileType.T_GROUND;
            }

            _tiles[172, 15]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;
            _tiles[178, 15]._tileType = Tile.TileType.T_CHICKEN_SPAWN_POSITION;

            _tiles[182, 13]._tileType = Tile.TileType.T_GROUND;

            _tiles[186, 15]._tileType = Tile.TileType.T_GROUND;

            _tiles[191, 17]._tileType = Tile.TileType.T_GROUND;

            for (int x = 195; x < 200; x++)
            {
                _tiles[x, 19]._tileType = Tile.TileType.T_BLOCKED;
                _tiles[x, 18]._tileType = Tile.TileType.T_GROUND;
            }

            //Basket
            _tiles[198, 17]._tileType = Tile.TileType.T_BASKET;

            
            return _tiles;
        }

    }
}
